import 'package:flutter/material.dart';

void main() => runApp(MyApp());

// 容器组件将装饰、大小限制、位置等属性融为一体
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('单一View滚动组件'),
        ),
        body: SingleChildScrollView(
          // 滚动方向
          scrollDirection: Axis.vertical,
          // 是否翻转滚动
          reverse: false,
          padding: EdgeInsets.all(12.0),
          // 如果有滚动嵌套，设置此view为主要滚动
          primary: true,
          // 滚动到底部的样式，Android的光圈、iOS的弹簧
          physics: ClampingScrollPhysics(),
          child: Column(
            children: [
              Container(
                color: Colors.blue,
                height: 200.0,
              ),
              Container(
                color: Colors.pink,
                height: 200.0,
              ),
              Container(
                color: Colors.redAccent,
                height: 200.0,
              ),
              Container(
                color: Colors.yellow,
                height: 200.0,
              ),
              Container(
                color: Colors.purple,
                height: 200.0,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
